<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="/js/jquery.2.1.4.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <script src="/layui/layui.js" charset="utf-8"></script>

    <script type="text/javascript">
        function modify() {
            var spass = $("#spass").val().trim();
            var npass = $("#npass").val().trim();
            var uid = ${user.uid};
            if (spass.length == 0 || npass.length == 0) {
                alert("密码不能为空");
                return;
            }
            $.post("/user/modify", {spass: spass, npass: npass, uid: uid}, function (data) {
                if (data == 0) {
                    $("#tip").html("<span style=\"color: red\">原密码错误！</span>");
                }
                if (data == 1) {
                    $("#tip").html("<span style=\"color: green\">密码修改成功！</span>");
                }
            });
        }
    </script>
</head>
<body>
<div style="margin: 15% 24% 10% 24%;text-align: center">
    <div id="tip" style="margin-bottom: 15px;font-size: 15px"></div>
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label style="height: 30px;padding-top: 5px" class="layui-form-label">原密码</label>
            <div class="layui-input-block">
                <input id="spass" type="password" style="width: 150px;height: 30px" name="username" required
                       lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label style="height: 30px;padding-top: 5px" class="layui-form-label">新密码</label>
            <div class="layui-input-block">
                <input id="npass" type="password" style="width: 150px;height: 30px" name="username" required
                       lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
    </form>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button style="float: left" class="layui-btn" lay-submit lay-filter="formDemo" onclick="modify();">提交
            </button>
        </div>
    </div>
</div>
</body>
</html>
